Serial Data Transmission in UART
RS232 Level Converter
Control and Status Registers :
Data Related Registers :
Baud Rate Setup related registers :
Interrupt Related Registers :
Programming Steps
Application
/* Name : main.c
* Purpose : Source code for UART Interfacing with ARM LPC2148.
* Author : Gemicates
* Date : 2018-02-02
* Website : www.gemicates.org
* Revision : None
*/
#include <lpc214x.h> // header file for LPC21XX series
void ser_init(void);
void tx(unsigned char c);
unsigned char rx(void);
void tx_string(unsigned char *s);
void main() // main function
{
ser_init();
tx('S');
}
void ser_init() // Funtion to Initialize UART
{
VPBDIV=0x02; // PCLK = 30MHz
PINSEL0|=0x05;
U0LCR=0x83;
U0DLL=195;
U0DLM=0;
U0LCR=0x03;
U0TER=(1<<7);
}
void tx(unsigned char c) // Funtion to transmit the data
{
U0THR=c;
while((U0LSR&(1<<5))==0);
}
void tx_string(unsigned char *s)
{
while(*s) {
tx(*s++);
}
}
unsigned char rx() // Funtion to recive the data
{
while((U0LSR&(1<<0))==0);
return U0RBR;
}